<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Browse extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$this->load->model('process_data');
		$this->load->model('searchlist');
		$this->load->helper('url');

		$data['searchList'] = $this->searchlist->get_search_list();
		$data['mainSubjects'] = $this->process_data->get_main_subjects();
		$data['subjects'] = $this->process_data->get_subjects();
		$data['curr_mainSubject'] = 0;
		$this->load->view('browse', $data);
	}

	public function subject()
	{
		$subjectName = $_GET['subjectName'];
		$fromAjax = (isset($_GET['fromAjax']))?$_GET['fromAjax']:"";
		$data['fromAjax'] = $fromAjax;
		$subjectName = urldecode($subjectName);
		if($subjectName != ''){
			$this->load->model('process_data');
			$this->load->model('searchlist');
			$this->load->helper('url');

			$data['searchList'] = $this->searchlist->get_search_list_subject($subjectName);
			$rSet = $this->searchlist->get_main_subject_id($subjectName);
			$data['curr_mainSubject'] = 0;
			if(count($rSet) > 0){
				$data['curr_mainSubject'] = $rSet[0]['main_subjects_ref'];
			}
			$data['mainSubjects'] = $this->process_data->get_main_subjects();
			$data['subjects'] = $this->process_data->get_subjects();
			$this->load->view('browse', $data);
		}
		else
		{
			//$this->index();
			echo "Unable to reach";
		}
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */